//
//  XCSingListButtonTableViewCell.m
//  SoundOfNature
//
//  Created by 梁新昌 on 16/3/15.
//  Copyright © 2016年 梁新昌. All rights reserved.
//

#import "XCSingListButtonTableViewCell.h"
#import "UIImageView+WebCache.h"
@implementation XCSingListButtonTableViewCell

- (void)dealloc {
    [_erJiButton release];
    [_songListImagView release];
    [_songListTitleLable release];
    [_songListListenCountLable release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.songListImagView = [[UIImageView alloc] initWithFrame:CGRectZero];
        self.songListImagView.userInteractionEnabled = YES;
        self.songListListenCountLable = [[XCBaseLable alloc] initWithFrame:CGRectZero];
        self.songListTitleLable = [[XCBaseLable alloc] initWithFrame:CGRectZero];
        self.erJiButton = [UIButton buttonWithType:UIButtonTypeSystem];
        
        
        [self.erJiButton setImage:[[UIImage imageNamed:@"Image-erji"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
        
        
        [self.contentView addSubview:self.songListImagView];
        [self.contentView addSubview:self.songListListenCountLable];
        [self.contentView addSubview:self.songListTitleLable];
        [self.contentView addSubview:self.erJiButton];
        
        
        
        [_songListListenCountLable release];
        [_songListTitleLable release];
        [_songListImagView release];
        
        
    }
    return self;
}

- (void)layoutSubviews {
    
    self.songListImagView.frame = CGRectMake(20, 20, self.bounds.size.width - 40, self.bounds.size.width - 80);
    self.songListTitleLable.frame = CGRectMake(20, self.songListImagView.frame.size.height + 25, self.bounds.size.width - 40, 21);
    self.songListListenCountLable.frame = CGRectMake(self.songListImagView.bounds.size.width - 50, 30, 30, 21);
    self.songListListenCountLable.font = [UIFont systemFontOfSize:10];
    self.songListListenCountLable.textColor = [UIColor whiteColor];
    
    self.erJiButton.frame = CGRectMake(self.songListImagView.bounds.size.width - 100, 30, 30, 30);
    
}
- (void)setSingListButtonModel:(XCSingListButtonModel *)singListButtonModel {
    if (_singListButtonModel != singListButtonModel) {
        [_singListButtonModel release];
        _singListButtonModel = [singListButtonModel retain];
    }
    
    [self.songListImagView sd_setImageWithURL:[NSURL URLWithString:singListButtonModel.pic_url]placeholderImage:[UIImage imageNamed:@"Image-p"]];
    
    self.songListListenCountLable.text = [NSString stringWithFormat:@"%.1f万", singListButtonModel.listen_count.floatValue / 10000];
    self.songListTitleLable.text = singListButtonModel.title;
    
}


- (void)awakeFromNib {
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    
}

@end
